/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package consoleBuilder;

import commands.ICommand;
import commands.ICommandContextuelle;
import context.IContext;
import general.ConsoleMutable;
import general.IConsole;

import java.io.InputStream;
import java.io.PrintStream;

/**
 *
 * eCOM - Adopte un Presta - Mars-Avril 2013
 * @author Kheira, Jef, William, Tuan-Long
 */
public class ConsoleBuilder {
    private ConsoleMutable console;

	public ConsoleBuilder() 
        {
            // Constucteur vide.
	}

	public void createNewShell(IContext context, 
                                    InputStream is, 
                                    PrintStream out, 
                                    PrintStream err) 
        {
		this.console = new ConsoleMutable(context, is, out, err);
	}

	public void createNewShell(IContext context) {
		this.console = new ConsoleMutable(context);
	}

	public ConsoleBuilder addCommand(ICommand command) {
		console.addCommand(command);
		return this;
	}

        
	public ConsoleBuilder addCommandContextuelle(ICommandContextuelle command) 
        {
		command.setContext(console.getContext());
		console.addCommand(command);
		return this;
	}
        

	public IConsole getShell() {
		return console;
	}

}
